#/usr/bin/python
# coding:utf8

import pymysql

conn = pymysql.connect("localhost","root","123456","test")
cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)

sql = 'select * from EEQA'

# 执行SQL
cursor.execute(sql)

# 取到查询结果
res1 = cursor.fetchone()
res2 = cursor.fetchmany(3)
res3 = cursor.fetchone()

# 关闭游标，数据库连接
cursor.close()
conn.close()

print(res1)
print(res2)
print(res3)

# 获取指定数量的数据
cursor.fetchmany(3)
# 光标按绝对位置移动1
cursor.scroll(1,mode="absolute")
# 光标按相对位置移动1
cursor.scroll(1,mode="relative")
